package com.wangshouyu.mp.pay.unified;

import com.thoughtworks.xstream.annotations.XStreamAlias;

import java.util.Objects;

/**
 * @author 王守钰
 * @description 统一下单范围结果
 * @date 2020/8/13 13:32
 */
@XStreamAlias(value = "xml")
public class UnifiedResponse extends BaseUnifiedResponse {

    /**
     * 业务结果
     * SUCCESS/FAIL
     */
    @XStreamAlias(value = "result_code")
    private String resultCode;

    /**
     * 对业务结果的补充说明
     */
    @XStreamAlias(value = "result_msg")
    private String resultMsg;

    /**
     * 错误代码
     * 当result_code为FAIL时返回错误代码
     */
    @XStreamAlias(value = "err_code")
    private String errCode;

    /**
     * 错误代码描述
     */
    @XStreamAlias(value = "err_code_des")
    private String errCodeDes;

    /**
     * 公众账号ID
     */
    @XStreamAlias(value = "appid")
    private String appId;

    /**
     * 商户号
     */
    @XStreamAlias(value = "appid")
    private String mchId;

    /**
     * 设备号
     */
    @XStreamAlias(value = "device_info")
    private String deviceInfo;

    /**
     * 随机字符串
     */
    @XStreamAlias(value = "nonce_str")
    private String nonceStr;

    /**
     * 签名
     */
    @XStreamAlias(value = "sign")
    private String sign;

    /**
     * 预支付交易会话标识
     */
    @XStreamAlias(value = "prepay_id")
    private String prepayId;

    /**
     * 交易类型
     * JSAPI -JSAPI支付
     * NATIVE -Native支付
     * APP -APP支付
     */
    @XStreamAlias(value = "trade_type")
    private String tradeType;

    /**
     * 用户openId
     */
    @XStreamAlias(value = "openid")
    private String openId;

    /**
     * 二维码链接
     */
    @XStreamAlias(value = "code_url")
    private String codeUrl;

    /**
     * 支付跳转链接
     */
    @XStreamAlias(value = "mweb_url")
    private String mwebUrl;

    public String getResultCode() {
        return resultCode;
    }

    public void setResultCode(String resultCode) {
        this.resultCode = resultCode;
    }

    public String getResultMsg() {
        return resultMsg;
    }

    public void setResultMsg(String resultMsg) {
        this.resultMsg = resultMsg;
    }

    public String getErrCode() {
        return errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public String getErrCodeDes() {
        return errCodeDes;
    }

    public void setErrCodeDes(String errCodeDes) {
        this.errCodeDes = errCodeDes;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getMchId() {
        return mchId;
    }

    public void setMchId(String mchId) {
        this.mchId = mchId;
    }

    public String getDeviceInfo() {
        return deviceInfo;
    }

    public void setDeviceInfo(String deviceInfo) {
        this.deviceInfo = deviceInfo;
    }

    public String getNonceStr() {
        return nonceStr;
    }

    public void setNonceStr(String nonceStr) {
        this.nonceStr = nonceStr;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }

    public String getPrepayId() {
        return prepayId;
    }

    public void setPrepayId(String prepayId) {
        this.prepayId = prepayId;
    }

    public String getTradeType() {
        return tradeType;
    }

    public void setTradeType(String tradeType) {
        this.tradeType = tradeType;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getCodeUrl() {
        return codeUrl;
    }

    public void setCodeUrl(String codeUrl) {
        this.codeUrl = codeUrl;
    }

    public String getMwebUrl() {
        return mwebUrl;
    }

    public void setMwebUrl(String mwebUrl) {
        this.mwebUrl = mwebUrl;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        UnifiedResponse that = (UnifiedResponse) o;
        return Objects.equals(resultCode, that.resultCode) &&
                Objects.equals(resultMsg, that.resultMsg) &&
                Objects.equals(errCode, that.errCode) &&
                Objects.equals(errCodeDes, that.errCodeDes) &&
                Objects.equals(appId, that.appId) &&
                Objects.equals(mchId, that.mchId) &&
                Objects.equals(deviceInfo, that.deviceInfo) &&
                Objects.equals(nonceStr, that.nonceStr) &&
                Objects.equals(sign, that.sign) &&
                Objects.equals(prepayId, that.prepayId) &&
                Objects.equals(tradeType, that.tradeType) &&
                Objects.equals(openId, that.openId) &&
                Objects.equals(codeUrl, that.codeUrl) &&
                Objects.equals(mwebUrl, that.mwebUrl);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), resultCode, resultMsg, errCode, errCodeDes, appId, mchId, deviceInfo, nonceStr, sign, prepayId, tradeType, openId, codeUrl, mwebUrl);
    }

    @Override
    public String toString() {
        return "UnifiedResponse{" +
                "resultCode='" + resultCode + '\'' +
                ", resultMsg='" + resultMsg + '\'' +
                ", errCode='" + errCode + '\'' +
                ", errCodeDes='" + errCodeDes + '\'' +
                ", appId='" + appId + '\'' +
                ", mchId='" + mchId + '\'' +
                ", deviceInfo='" + deviceInfo + '\'' +
                ", nonceStr='" + nonceStr + '\'' +
                ", sign='" + sign + '\'' +
                ", prepayId='" + prepayId + '\'' +
                ", tradeType='" + tradeType + '\'' +
                ", openId='" + openId + '\'' +
                ", codeUrl='" + codeUrl + '\'' +
                ", mwebUrl='" + mwebUrl + '\'' +
                '}';
    }
}
